package main

import "fmt"

type Bag struct {
	items []int
}

//引用传递，指针模式
func (b *Bag) Insert(itemid int) {
	b.items = append(b.items, itemid)
}

//此处是值传递
func (b Bag) Insert2(itemid int) {
	b.items = append(b.items, itemid)
}

func main() {
	b := new(Bag)
	b.Insert(1001)
	fmt.Println(*b) //{[1001]},成功赋值
	c := new(Bag)
	c.Insert2(1)
	fmt.Println(*c) //{[]}，并没有生效
}
